import { ApiProperty } from '@nestjs/swagger';
import { IsNumber, IsString, IsOptional, IsEnum } from 'class-validator';

/**
 * 调账类型枚举
 */
export enum AdjustType {
  BALANCE = 'balance',
  VOUCHER = 'voucher',
}

/**
 * 调账操作枚举
 */
export enum AdjustOperation {
  ADD = 'add',
  SUBTRACT = 'subtract',
  SET = 'set',
}

/**
 * 钱包调账DTO
 */
export class AdjustWalletDto {
  @ApiProperty({ description: '用户ID', example: 1 })
  @IsNumber()
  userId: number;

  @ApiProperty({ 
    description: '调账类型', 
    enum: AdjustType,
    example: AdjustType.BALANCE 
  })
  @IsEnum(AdjustType)
  type: AdjustType;

  @ApiProperty({ 
    description: '调账操作', 
    enum: AdjustOperation,
    example: AdjustOperation.ADD 
  })
  @IsEnum(AdjustOperation)
  operation: AdjustOperation;

  @ApiProperty({ description: '调账金额（单位：分）', example: 1000 })
  @IsNumber()
  amount: number;

  @ApiProperty({ description: '调账原因', example: '充值失败补偿', required: false })
  @IsOptional()
  @IsString()
  reason?: string;
}